<template>
  <div id="app">
    <nav v-if="isAuthenticated">
      <router-link to="/">Home</router-link> |
      <router-link to="/public-activities">公开活动</router-link>
      <span v-if="isAdmin"> | <router-link to="/activity-management">活动管理</router-link></span>
    </nav>
    <router-view/>
  </div>
</template>

<script>
export default {
  computed: {
    isAuthenticated() {
      return !!localStorage.getItem('user');
    },
    isAdmin() {
      const user = JSON.parse(localStorage.getItem('user'));
      return user && user.role === 'admin';
    }
  }
};
</script>